<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>测试前端框架</title>
    <meta name="description" content="">
    <meta name="keywords" content="">
    <link href="" rel="stylesheet">
    <script type="text/javascript" src="/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="/bower_components/jquery/dist/jquery.min.js"></script>
    <script type="text/javascript" src="/dist/js/adminlte.min.js"></script>


    <link rel="stylesheet" type="text/css" href="/dist/css/AdminLTE.min.css">
    <link rel="stylesheet" type="text/css" href="/bower_components/bootstrap/dist/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="/bower_components/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="/bower_components/Ionicons/css/ionicons.min.css">
    <link rel="stylesheet" type="text/css" href="/dist/css/skins/skin-blue.min.css">
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

    <!-- Main Header -->
    <header th:include="admin_public :: header" class="main-header">
    </header>


    <!-- Left side column. contains the logo and sidebar -->
    <aside th:include="admin_public :: sidebar" class="main-sidebar">
    </aside>

    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">

        <section class="content container-fluid">

            <div>
                <!-- Horizontal Form -->
                <div class="box box-info">
                    <div class="box-header with-border">
                        <h3 class="box-title">用户管理-添加用户</h3>
                    </div>
                    <!-- /.box-header -->
                    <!-- form start -->
                    <div class="form-horizontal">
                        <div class="box-body">
                            <div class="form-group">
                                <label for="UserName" class="col-sm-2 control-label">用户名</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id="UserName" placeholder="UserName">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="Password" class="col-sm-2 control-label">用户密码</label>
                                <div class="col-sm-10">
                                    <input type="password" class="form-control" id="Password" placeholder="Password">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="Sex" class="col-sm-2 control-label">性别</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id="Sex" placeholder="Sex">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="Birthday" class="col-sm-2 control-label">生日</label>
                                <div class="col-sm-10">
                                    <input type="date" class="form-control" id="Birthday" placeholder="Birthday">
                                </div>
                            </div>
                        </div>
                        <!-- /.box-body -->
                        <div class="box-footer">
                            <button type="submit" class="btn btn-success btn-flat" onclick="addUser()">新增</button>
                        </div>
                        <!-- /.box-footer -->
                    </div>
                </div>
                <!-- /.box -->
            </div>

        </section>

    </div>
    <!-- /.content-wrapper -->

    <!-- Main Footer -->
    <footer th:include="admin_public :: footer" class="main-footer">
    </footer>

    <!-- Control Sidebar -->
    <aside th:include="admin_public :: control" class="control-sidebar control-sidebar-dark">
    </aside>

    <div class="control-sidebar-bg">
    </div>

    <script>

        function addUser() {

            var user = {
                userName: $("#UserName").val(),
                password: $("#Password").val(),
                sex: $("#Sex").val(),
                birthday: $("#Birthday").val()
            };
            $.ajax({
                type: 'post',
                url: "/admin/user/addUser",
                //headers: {'Content-type': 'application/json;charset=UTF-8'},
                contentType: 'application/json;charset=UTF-8',
                dataType: "json",
                data: JSON.stringify(user),
                success: function (result) {
                    alert("添加成功");
                    window.location.href = "/admin/user/selectUser"
                },
                error: function (result) {
                    alert("失败了");
                }
            })
        }

    </script>
</div>
</body>
</html>